const express = require("express");
var multer = require("multer");
const router = express.Router();
const { uploadHandler } = require("../router_handler/index.js");
var upload = multer({
  dest: "upload/",
  fileFilter(req, file, callback) {
    // 解决中文名乱码的问题
    file.originalname = Buffer.from(file.originalname, "latin1").toString("utf8");
    callback(null, true);
  },
});
router.post("/upload", upload.single("myfile"), uploadHandler.upload);
router.get("/download/:name",  uploadHandler.download);
module.exports = router;
